package com.go.where.family.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.go.where.family.dao.BigClassDao;
import com.go.where.family.dao.VideoDao;
import com.go.where.family.pojo.BigClassInfo;
import com.go.where.family.pojo.VideoInfo;
import com.go.where.family.service.VideoService;

@Service("videoService")
public class VideoServiceImpl implements VideoService {

	@Resource(name = "videoDao")
	private VideoDao videoDao;
	@Resource(name = "bigClassDao")
	private BigClassDao bigClassDao;

	@Override
	public List<VideoInfo> queryList(Map<String, Object> map) {
		return videoDao.queryT(map);
	}

	@Override
	public List<VideoInfo> queryGroupByBigClassAndTime() {
		List<VideoInfo> list = videoDao.queryGroupByBigClassAndTime();
		if (list != null && !list.isEmpty()) {
			for (VideoInfo vi : list) {
				String bigClassId = vi.getBigClassId();
				BigClassInfo big = new BigClassInfo();
				big.setClassId(bigClassId);
				BigClassInfo bci = bigClassDao.queryByPrimaryKey(big);
				vi.setBigName(bci.getClassName());
			}
		}
		return list;
	}

	@Override
	public VideoInfo queryVideoDetail(String videoId) {
		VideoInfo vi = new VideoInfo();
		vi.setVideoId(videoId);
		return videoDao.queryByPrimaryKey(vi);
	}

	@Override
	public int update(VideoInfo videoInfo) {
		return videoDao.update(videoInfo);
	}

}
